package geektime.io.nio;

import java.nio.charset.Charset;
import java.util.*;

public class CharsetDemo {
    public static void main(String[] args) {
        // 打印nio默认的编码规则
        Charset charset = Charset.forName("GB18030");
        System.out.println("Default charset: " + charset.defaultCharset()); // UTF-8
        // 打印可供选择的编码规则
        SortedMap<String, Charset> charsetMap = charset.availableCharsets();
        for (Map.Entry<String, Charset> entry : charsetMap.entrySet()) {
            System.out.println(entry.getKey() + ": " + entry.getValue());
        }
    }
}
